package net.steam.easyjoboa.web.action;

import java.util.List;

import net.steam.easyjoboa.biz.MessageBiz;
import net.steam.easyjoboa.biz.ProclaimBiz;
import net.steam.easyjoboa.entity.Employee;
import net.steam.easyjoboa.entity.Message;
import net.steam.easyjoboa.entity.PageBean;
import net.steam.easyjoboa.entity.PageBeans;
import net.steam.easyjoboa.entity.Proclaim;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

public class MainAction {
	private Message message;
	private PageBeans pbs;
	private PageBean pb;
	private int page = 1;
	private MessageBiz messageBiz;
	List<Message> noReadMessages;
	private List<Proclaim> proclaims;
	private ProclaimBiz proclaimBiz;
	
	
	
	/**
	 * main.jsp 显示有效公告.未读消息
	 * @return
	 */
	@Action(value = "showMain",results={
			@Result(name="success",location="/main.jsp"),
			@Result(name="error",location="/error.jsp")
			})
	public String showMainMeg(){
		if(pbs==null || pb==null){
			pbs = new PageBeans();
			pb =new PageBean();
		}
		Employee loginUser = (Employee) ServletActionContext.getRequest().getSession().getAttribute("loginUser");
		
		pbs.setCurrentPage(page);
		pbs.setPageSize(6);
		noReadMessages = messageBiz.findInBoxNoRead(pbs, message, loginUser.getUserId());
		
		pb.setPageSize(6);
		proclaims=proclaimBiz.seeProclaim(pb);
		if(proclaims !=null ||noReadMessages !=null) {
			return "success";
		}else {
			return "error";
			
		}
		
	}



	public Message getMessage() {
		return message;
	}



	public void setMessage(Message message) {
		this.message = message;
	}



	public PageBeans getPageBean() {
		return pbs;
	}



	public void setPageBean(PageBeans pageBean) {
		this.pbs = pageBean;
	}



	public int getPage() {
		return page;
	}



	public void setPage(int page) {
		this.page = page;
	}



	public MessageBiz getMessageBiz() {
		return messageBiz;
	}



	public void setMessageBiz(MessageBiz messageBiz) {
		this.messageBiz = messageBiz;
	}



	public List<Message> getNoReadMessages() {
		return noReadMessages;
	}



	public void setNoReadMessages(List<Message> noReadMessages) {
		this.noReadMessages = noReadMessages;
	}



	public List<Proclaim> getProclaims() {
		return proclaims;
	}



	public void setProclaims(List<Proclaim> proclaims) {
		this.proclaims = proclaims;
	}



	public ProclaimBiz getProclaimBiz() {
		return proclaimBiz;
	}



	public void setProclaimBiz(ProclaimBiz proclaimBiz) {
		this.proclaimBiz = proclaimBiz;
	}



	public PageBeans getPbs() {
		return pbs;
	}



	public void setPbs(PageBeans pbs) {
		this.pbs = pbs;
	}



	public PageBean getPb() {
		return pb;
	}



	public void setPb(PageBean pb) {
		this.pb = pb;
	}

}
